#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QCloseEvent>
#include <QIcon>
#include <QMainWindow>
#include <QMenu>
#include <QMessageBox>
#include <QStandardItemModel>
#include <QSystemTrayIcon>
#include <QTcpSocket>
#include <QThread>
#include <QTimer>
#include <QVector>
#include <QtNetwork>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

struct TSchool
{
    QString id, ekis, name, address;
};

struct TSchoolAddres
{
    QString schoolid, id, ekis, name, address;
};

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:

    void checkUDS();
    void on_RoleCombobox_currentIndexChanged(int index);
    void on_TypeCombobox_currentIndexChanged(int index);
    void on_actionGeneration_hostname_triggered();
    void on_applyButton_clicked();
    void on_buildingstable_clicked(const QModelIndex &index);
    void on_chNameandRestart_clicked();
    void on_cpUDSID_clicked();
    void on_schooltable_clicked(const QModelIndex &index);
    void on_searchButton_clicked();
    void on_showHelp_triggered();
    void on_sugnameButton_clicked();
    void readVariablesFromUI();
    void replybuildingslist(QNetworkReply *reply);
    void replyschoolist(QNetworkReply *reply);
    void showIdentificationMessage();

private:
    Ui::MainWindow *ui;
    QStandardItemModel* schoolsmodel;
    QStandardItemModel* buildingsmodel;
    QVector<TSchool> dbSch;
    QVector<TSchoolAddres> dbSchools;
    QString sid, sekis, invn, room, dtype, drole, sfullname, sfulladdr, schoolid, sughostname;
    bool checkbase = true;
    QSystemTrayIcon* m_trayIcon;
    QTimer *identifyTimer;
    QTimer *udsTimer;
    QString appicon;
    QString statusMessage;
    QString rq = "ogNpzMEUBhDTRV1TOJHUwJnV1kUeJlDehVXay1WY6NHS3kWVqRFaF52Q8lDIyVmchVm1Q";

    // Функции
    QString genhostname();
    void closeEvent(QCloseEvent *event) override;
    void school_model_settings();
};
#endif // MAINWINDOW_H
